package com.gmq.utils;

import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;

public  class GetUserId {
    private JwtUtils jwtUtils = new JwtUtils();
    @Autowired
    private JwtProperties jwtProperties;
    @Autowired
    private HttpServletRequest httpServletRequest;

    public Long getUserid() {
        return Long.valueOf(
                String.valueOf(jwtUtils.parseJwt(jwtProperties.getUserSecretKey(),
                        httpServletRequest.getHeader("authentication")).get("userId"))
        );
    }
}
